<?php
include_once('connection/connection.php');
include('header.php');
include('menu.php');
include('config.php');
$frm=$_SESSION['form_id'];
$id1=$_SESSION['id1'];
$qrVillage="select * from tbl_dtls_ufw_src_village where loc_id='$id1'";
                    $resVillage=mysql_query($qrVillage);
                    $rowVillage=mysql_fetch_array($resVillage);
					$Final_Path=$rowVillage['district'] ;
$path = $_SERVER['DOCUMENT_ROOT']."/rajasthan/administrator/photo/$Final_Path/"; // change the path to fit your websites document structure
$fullPath = $path.$_REQUEST['download_file'];
 
if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;
?>